package ooday04;

public class Test {
    public static void main(String[] args) {
        /*
        Dog[] dogs = new Dog[3];
        dogs[0] = new Dog("小黑",1,"黑");
        dogs[1] = new Dog("小白",1,"白");
        dogs[2] = new Dog("小灰",1,"灰");
        dogs[2].swim();
        for (int i = 0;i< dogs.length;i++){
            System.out.println(dogs[i].name);
            dogs[i].eat();
        }



        Chick[] chicks = new Chick[3];
        chicks[0] = new Chick("小金",1,"金");
        chicks[1] = new Chick("小黑",2,"黑");
        chicks[2] = new Chick("小蓝",3,"蓝");
        for (int i = 0;i< chicks.length;i++){
            System.out.println(chicks[i].name);
            chicks[i].eat();

        }

        Fish[] fish = new Fish[3];
        fish[0] = new Fish("小白",1,"白");
        fish[1] = new Fish("小黑",2,"黑");
        fish[2] = new Fish("小黄",3,"黄");
        for (int i =0;i< fish.length;i++){
            System.out.println(fish[i].name);
            fish[i].swim();
        }

         */

       Animal[] animals = new Animal[5];
       animals[0] = new Dog("小黑",1,"黑");
       animals[1] = new Dog("小白",2,"白");
       animals[2] = new Fish("小银",3,"银");
       animals[3] = new Fish("小花",4,"花");
       animals[4] = new Chick("小金",5,"金");
       for (int i = 0;i<animals.length;i++){
           System.out.println(animals[i].name);
           animals[i].eat();

           if(animals[i] instanceof Dog){
               Dog dog = (Dog) animals[i];
               dog.swim();
               dog.lookHome();
           }
           if (animals[i] instanceof Chick){
               Chick chick = (Chick)animals[i];
               chick.layEggs();
           }
           if (animals[i] instanceof Swim){
               Swim s = (Swim) animals[i];
               s.swim();
           }

       }


        /*
        Master master = new Master();
        Dog dog = new Dog("小黑",1,"黑");
        Fish fish = new Fish("小金",3,"金");
        Chick chick = new Chick("小白",2,"白");
        master.feed(dog);
        master.feed(fish);
        master.feed(chick);

         */

    }
}
